<template>
	<view>

		<view class="matrix">
			<view class="matrix_top">
				<h2>铁建投城发项目官微矩阵</h2>
				<span>HENAN RCIC</span>
				<image class="two" src="https://tjyzsz.oss-cn-beijing.aliyuncs.com/ohter/static/matrix_top.jpg"
					alt="" />
				</image>
			</view>
			<view class="matrix_img">
				<view class="matrix_img_within" v-for="item in jsonData" @click="goDetail(item)">
					<image class="one" :src="item.thumb" alt="" />
					</image>
					<span>{{item.title}}</span>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				jsonData: [],
				allpage: 0,
				page: 1,
				limit: 10,
			}
		},
		onLoad() {
			this.getIndex();
		},
		onReachBottom() {
			var _this = this;
			console.log(this.allpage);
			if (this.allpage > this.jsonData.length) {
				_this.getIndex();
			} else {
				_this.ending = true;
			}
		},
		methods: {
			//获取数据
			getIndex() {
				uni.showLoading({
					title: "获取中…"
				})
				uni.$u.http.post("/news/index", {
					class_id: 3,
					limit: this.limit,
					page: this.page
				}).then((res) => {
					if (res.code == 200) {
						this.allpage = res.data.total;
						if (this.page == 1) {
							this.jsonData = res.data.data;
							this.page++;
						} else {
							this.jsonData = this.jsonData.concat(res.data.data);
							if (res.data.data.length >= 1) {
								this.page++;
							}
						}
					}
					uni.hideLoading();
				})
			},

			goDetail(ele) {
				if (ele.urls) {
					// #ifdef MP-WEIXIN
					//const wx = uni.$mp.weixin;
					wx.openOfficialAccountArticle({
						url: ele.urls, // 此处填写公众号文章连接
						success: res => {},
						fail: res => {}
					})
					// #endif
					// #ifdef H5
					window.open(ele.urls, '_blank');
					// #endif

				} else {
					uni.navigateTo({
						url: "/pages/index/news_det?id=" + ele.id
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.matrix {
		padding: 60rpx 100rpx;

		.matrix_top {
			width: 100%;
			text-align: center;

			h2 {
				font-weight: normal;
				font-size: 40rpx;
				line-height: 70rpx;
			}

			span {
				letter-spacing: 12rpx;
				display: block;
				font-size: 24rpx;
			}

			.two {
				width: 100%;
				margin-top: 20rpx;
				height: 22rpx;
			}
		}

		.matrix_img {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			view.matrix_img_within {
				width: 50%;
				text-align: center;
				margin: 6% 0;

				.one {
					width: 160rpx;
					height: 160rpx;
					border-radius: 12rpx;
					box-shadow: -1px 0 24rpx rgba(0, 0, 0, .1), 1px 0 24rpx rgba(0, 0, 0, .1), 0 -1px 24rpx rgba(0, 0, 0, .1), 0 1px 24rpx rgba(0, 0, 0, .1);
				}

				span {
					display: block;
					color: #666;
					line-height: 48rpx;
					font-size: 28rpx;
				}
			}
		}
	}
</style>